Java EE Applications on Oracle Java Cloud:: Develop, Deploy, Monitor, and Manage Your Java Cloud Applications by Harshad Oak

Java EE Applications on Oracle Java Cloud:: Develop, Deploy, Monitor, and Manage Your Java Cloud Applications by Harshad Oak

Author:Harshad Oak [Oak, Harshad]
Language: eng
Format: epub
Tags: Computers, Web, Web Programming, Certification, Databases, Java, JavaScript
ISBN: 9780071817165
Google: W1lzAwAAQBAJ
Publisher: McGraw Hill Professional
Published: 2014-09-04T21:00:00+00:00


JSP Comments

Comments are used throughout programming as a best practice to communicate your ideas or as an approach to addressing a particular issue within the code. In JSP, you have three choices for how you want to use comments—JSP Comment, Java Comment, and HTML Comment (see Listing 5-6).

Listing 5-6: JSP Comments

The difference between these three is that the JSP Comment appears only in the JSP and not even in the translated Servlet code. The Java Comment appears in the JSP and the Servlet code, whereas HTML Comment is the only one that will make it to the response (usually HTML) and can be viewed if the user selects View Source in the web browser.

None of the styles of comments will affect the output of the JSP page, but understanding where the comments appear is vital for you to be able to use the right kind of comment at the right place. If the comment is meant only for the JSP developers, you should use the <%-- JSP Comment --%> style of commenting. The <!-- HTML Comment --> style should be used only if you want the comment to appear in the HTML response. Although it’s true that the <!-- HTML Comment --> comments are visible only if someone checks the source in the browser, you would still be moving a lot of unnecessary data to the client and also reveal developer-specific information.

The <% //Java Comment %> comment type is the one that Java developers are comfortable with and often end up using. However, it has no real benefit over the JSP Comment, because including the comment in the translated Servlet usually does not serve much purpose. So in most cases, JSP Comment will be the one to use.

In this section, we looked at the working of the JSP, the basic syntax, and usage of directives, scriptlets, expressions, and comments. Let’s now look at how you can use tags to make your JSPs fast to build and easy to maintain.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.